package com.inspur.demo.controller;

import com.inspur.demo.common.CommResultMsg;
import com.inspur.demo.common.CommonResultBuilder;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 *    
 * feignController
 *
 * @desc:
 * @author: li.peng02
 * @date: 2019/3/15
 * @version: v1.0 
 */
@RestController
@RequestMapping("/feign")
public class ProduceFengnController {

    @GetMapping("/get/{id}")
    public String get(@PathVariable String id) {
        return id;
    }

    @RequestMapping("/getResult01/{id}")
    public CommResultMsg getResult01(@PathVariable(value = "id") String id) {
        CommResultMsg comm = new CommResultMsg();
        CommonResultBuilder.build(comm, true, "SUCCESS", id);
        return comm;
    }

    @GetMapping("/getResult02")
    public CommResultMsg getResult02(boolean result, String description) {
        CommResultMsg commResultMsg = new CommResultMsg();
        commResultMsg.setResult(result);
        commResultMsg.setDescription(description);
        return commResultMsg;
    }

    @PostMapping("/postResult")
    public CommResultMsg postResult01(@RequestBody CommResultMsg comm) {
        return comm;
    }

    @GetMapping("/list")
    public List<CommResultMsg> list() {
        List<CommResultMsg> commResultMsgs = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            commResultMsgs.add(new CommResultMsg());
        }
        return commResultMsgs;
    }

}
